<?php

class Debug {

    private static $instance;
    private $logFile;
    private $start;
    private $end;

    public static function getInstance() {
        if( !is_object(self::$instance) ) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    public function log( $StMessage, $StFile = 'log.txt' ) {
        $TxContent = file_get_contents($StFile) . "\n" . now() . ': ' .$StMessage;
        $this->logFile = fopen($StFile, 'w+');
        fwrite($this->logFile, $TxContent, strlen($TxContent));
        fclose($this->logFile);
    }

    public function cleanLog() {

    }

    public function initCounter() {
        $this->start = microtime();
    }

    public function endCounter() {
        $this->end = microtime();
    }

    public function getCounter() {
        return $this->end - $this->start;
    }

    public function getPartialTime() {
        $partial = microtime();
        return $partial - $this->start;
    }

}

?>